//
// Created by W.yk on 2022/5/25.
//

#ifndef B_PLUS_DB_SERVER_H
#define B_PLUS_DB_SERVER_H

#include "../buffer/buffer.h"
#include "../buffer/buffer_pool.h"
#include "../innodb/page.h"
#include <string>
#include <vector>

class Server {
private:
    std::shared_ptr<BufferPool> instance;
    int has_searched_num;

public:
    Server() { instance = BufferPool::getInstance(); }


    void insert_value(int id, const unsigned char *c1, const unsigned char *c2,
                      const unsigned char *c3, const unsigned char *c4);

    int insert_from_csv(const std::string &path);

    COMPACT_DATA *search_one_piece(int value);

    std::vector<COMPACT_DATA> search_in_range(int value1, int value2);
    //    COMPACT_DATA **search_in_range(int value1, int value2);

    void insert_into_csv_in_range(std::string path, int value1, int value2);

    void shutdown();

    int get_has_searched_num() const;

    ~Server() { instance->destroy(); };
};

#endif // B_PLUS_DB_SERVER_H
